#ifndef DATA_STORAGE_H
#define DATA_STORAGE_H

#include "Arduino.h"
#include "mail.h"
#include <DataStorageBase.h>
#include "module_header_reg.h"
#include <Scheduler.h>
class DataStorage : public DataStorageBase,public Scheduler
{
public:
    typedef enum 
    {
        StatusNumber0 = 0,
        StatusNumber1 = 1,
        StatusNumber2 = 2,
        StatusNumber3 = 3
    }GeneralStatusName;

    DataStorage(DataStorageBase* _db);
    virtual ~DataStorage();

    void begin();

    bool load()override
    {
        return _db->load();
    }
    
    void make_default() override
    {
        _db->make_default();
    }
    
    data_storage_reg_read_t& get_reg_data(uint8_t reg_address) override
    {
        return _db->get_reg_data(reg_address);
    }
    
    int read_data_storage_eof() override
    {
        return _db->read_data_storage_eof();
    }
    
    void check_update() override
    {   
        _db->check_update();
    }

    module_header_reg_t& module_header_reg() override
    {
        return _db->module_header_reg();
    }

    void schedule() override;
    void update() override;
    void dispatch(uint8_t* data,size_t size) override{};
    void cleanup() override;
private:
    
    DataStorageBase* _db;
    bool _update;
    unsigned long _last_millis;
};


#endif